import http from '@/utils/http'

const BASE_URL = '/music/copyright'

export interface CopyrightResp {
  id: string
  songName: string
  lyricist: string
  composer: string
  singer: string
  lyricCopyrightCompany: string
  musicCopyrightCompany: string
  createUserString: string
  updateUserString: string
  disabled: boolean
}
export interface CopyrightDetailResp {
  id: string
  songName: string
  lyricist: string
  composer: string
  singer: string
  lyricCopyrightCompany: string
  musicCopyrightCompany: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface CopyrightQuery {
  songName: string | undefined
  lyricist: string | undefined
  composer: string | undefined
  singer: string | undefined
  lyricCopyrightCompany: string | undefined
  musicCopyrightCompany: string | undefined
  sort: Array<string>
}
export interface CopyrightPageQuery extends CopyrightQuery, PageQuery {}


export interface CopyrightImportResp {
  importKey: string
  totalRows: number
  validRows: number
  duplicateLyricsMusicRows: number
}

export interface CopyrightImportReq {
  importKey: string
  errorPolicy: number
  duplicateSong: number
  invalidFormat: number
  defaultStatus: number
}

/** @desc 查询版权管理列表 */
export function listCopyright(query: CopyrightPageQuery) {
  return http.get<PageRes<CopyrightResp[]>>(BASE_URL, query)
}

/** @desc 查询版权管理详情 */
export function getCopyright(id: string) {
  return http.get<CopyrightDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增版权管理 */
export function addCopyright(data: any) {
  return http.post(BASE_URL, data)
}

/** @desc 修改版权管理 */
export function updateCopyright(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除版权管理 */
export function deleteCopyright(id: string) {
  return http.del(BASE_URL, { ids: [id] })
}

/** @desc 导出版权管理 */
export function exportCopyright(query: CopyrightQuery) {
  return http.download(`${BASE_URL}/export`, query)
}

/** @desc 下载版权导入模板 */
export function downloadCopyrightImportTemplate() {
  return http.download(`${BASE_URL}/import/template`)
}

/** @desc 解析版权导入数据 */
export function parseImportCopyright(data: FormData) {
  return http.post<CopyrightImportResp>(`${BASE_URL}/import/parse`, data)
}

/** @desc 导入版权数据 */
export function importCopyright(data: CopyrightImportReq) {
  return http.post<{ insertRows: number; updateRows: number }>(`${BASE_URL}/import`, data)
}
